package com.xiegang.internalcommon.dto;

import com.xiegang.internalcommon.constant.CommonStatusEnum;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.xml.ws.Response;

/**
 * @author xieGang
 * @description
 * @date 2023/3/1 16:52
 **/

@Data
@Accessors(chain = true)
public class ResponseResult<T> {

    private int code;
    private String message;
    private T data;


    public static <T> ResponseResult success(){
        return new ResponseResult().setCode(CommonStatusEnum.SUCCESS.getCode()).setMessage(CommonStatusEnum.SUCCESS.getMessage()).setData("");
    }
    /***
     * @description 成功：自定义data
     * @author xieGang
     * @date 2023/3/1 16:59
     * @param data
     * @return com.xiegang.internalcommon.dto.ResponseResult
     */
    public static <T> ResponseResult success(T data){
        return new ResponseResult().setCode(CommonStatusEnum.SUCCESS.getCode()).setMessage(CommonStatusEnum.SUCCESS.getMessage()).setData(data);
    }

    /***
     * @description 错误：统一
     * @author xieGang
     * @date 2023/3/1 17:03
     * @param data
     * @return com.xiegang.internalcommon.dto.ResponseResult
     */
    public static <T> ResponseResult fail(T data){
        return new ResponseResult().setData(data);
    }

    /***
     * @description 失败：自定义编码、提示信息
     * @author xieGang
     * @date 2023/3/1 17:00
     * @param code
     * @param message
     * @return com.xiegang.internalcommon.dto.ResponseResult
     */
    public static ResponseResult fail(int code,String message){
        return new ResponseResult().setCode(code).setMessage(message);
    }

    /***
     * @description 失败：自定义编码、提示信息、具体数据
     * @author xieGang
     * @date 2023/3/1 17:02
     * @param code
     * @param message
     * @param data
     * @return com.xiegang.internalcommon.dto.ResponseResult
     */
    public static <T> ResponseResult fail(int code,String message,T data){
        return new ResponseResult().setCode(code).setMessage(message).setData(data);
    }


}
